<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateTableForFileData extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('file', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->timestamps();
            $table->integer('module_id')->comment('模块id 用于关联数据')
                ->index('module_id');
            $table->integer('event_id')->comment('事件id，关联事件')->index();
            $table->integer('index')->comment('索引，一个模块需要多个文件位置的时候可用')->default(0);
            $table->char('class', 32)->comment('班级')->default(0);
            $table->string('path', 255)->comment('文件地址')->default('');
            $table->string('file_name', 255)->comment('文件名')->default('');
            $table->string('suffix', 32)->comment('文件后缀')->default('')->default('');
            $table->integer('size')->comment('文件大小，单位kb')->default(0)->nullable(false);
            $table->string('created_by', 32)->comment('上传文件的人')->default('');
            $table->integer('created_id')->comment('上传文件人id')->default(0)->nullable(false);

        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('table_for_file_data');
    }
}
